#include "StringManipulator.h"

void stringManipulator::packstring(vector<string>& stream){
    
    int position=0;
    
    while(stream.size()>position){
         resultstream.push_back(stream.at(position));
         position++;
    }

}
void stringManipulator::splitstream(string inputstring , const string patterntobesearch) {
      split(modifiedstream,inputstring,is_any_of(patterntobesearch));
      packstring(modifiedstream);
}

vector<string> stringManipulator::getstream(){
    return resultstream;
}

void stringManipulator::clear_result_stream(){
    resultstream.clear();
}

void stringManipulator::findandreplace(string inputstring, const string patterntobesearch, const string substitutestring ){
     vector<string> replacedstream;
     
     replace_all(inputstring, patterntobesearch, substitutestring);
     replacedstream.push_back(inputstring);
     packstring(replacedstream);
    // replacedstream.clear(); //Intially declared as class data member but moved sd locsl method variable
                               //Needs to clear vector as data items are pushback.
                               //I believe this can be remedied by using local variables
 }

